load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
    name = "go_default_library",
    srcs = ["sidecar_shim.go"],
    importpath = "kubevirt.io/kubevirt/cmd/sidecars",
    visibility = ["//visibility:private"],
    deps = [
        "//pkg/cloud-init:go_default_library",
        "//pkg/hooks:go_default_library",
        "//pkg/hooks/info:go_default_library",
        "//pkg/hooks/v1alpha1:go_default_library",
        "//pkg/hooks/v1alpha2:go_default_library",
        "//pkg/hooks/v1alpha3:go_default_library",
        "//staging/src/kubevirt.io/api/core/v1:go_default_library",
        "//staging/src/kubevirt.io/client-go/log:go_default_library",
        "//vendor/github.com/spf13/pflag:go_default_library",
        "//vendor/k8s.io/apimachinery/pkg/util/rand:go_default_library",
        "@org_golang_google_grpc//:go_default_library",
    ],
)

go_binary(
    name = "sidecar-shim",
    embed = [":go_default_library"],
    visibility = ["//visibility:public"],
)

load(
    "@io_bazel_rules_docker//container:container.bzl",
    "container_image",
)

container_image(
    name = "sidecar-shim-image",
    architecture = select({
        "@io_bazel_rules_go//go/platform:linux_arm64": "arm64",
        "@io_bazel_rules_go//go/platform:linux_s390x": "s390x",
        "//conditions:default": "amd64",
    }),
    base = "//:passwd-image",
    directory = "/",
    entrypoint = ["/sidecar-shim"],
    files = [":sidecar-shim"],
    tars = select({
        "@io_bazel_rules_go//go/platform:linux_s390x": [
            "//rpm:sidecar-shim_s390x",
        ],
        "@io_bazel_rules_go//go/platform:linux_arm64": [
            "//rpm:sidecar-shim_aarch64",
        ],
        "//conditions:default": [
            "//rpm:sidecar-shim_x86_64",
        ],
    }),
    visibility = ["//visibility:public"],
)
